package com.qdaily.ui.net;

import android.content.Context;
import android.os.Handler;
import com.qdaily.supportlibrary.request.CacheAbleRequest;
import com.qdaily.supportlibrary.request.FailData;
import com.qdaily.supportlibrary.request.JsonData;
import com.qdaily.supportlibrary.util.NetUtil;
import com.qdaily.supportlibrary.util.NetUtil.NetDataCallBack;
import com.qdaily.supportlibrary.util.NetUtil.NetParams;
import com.qdaily.supportlibrary.util.QLog;
import com.qdaily.ui.util.QDUtil;
import com.qdaily.ui.util.ToastUtil;

import java.io.File;

/**
 * 业务的网络处理
 *
 * @author chencheng
 * @version 1.0
 * @time Mar 26, 20153:42:20 PM
 * @contact lovejiuwei@gmail.com
 */

public class QdailyNetwork {
    private final String TAG = "QdailyNetwork";
    private OnRequestCallBackListener onRequestCallBackListener;
    private Context mContext;

    public QdailyNetwork(Context context, OnRequestCallBackListener onRequestCallBackListener) {
        this.mContext = context;
        this.onRequestCallBackListener = onRequestCallBackListener;
    }

    /**
     * 网络请求成功以后，会返回当前的网络拼接参数以及gson解析以后的模板。
     *
     * @author chencheng
     * @version 1.0
     * @time Mar 28, 20152:01:22 PM
     * @contact lovejiuwei@gmail.com
     */
    public interface OnRequestCallBackListener {
        /**
         * @param params   网络参数的封装
         * @param response 回调结果
         */
        void onResponse(NetParams params, JsonData response);

        void onResponseCache(NetParams params, JsonData response);

        void onResponseError(NetParams params, Object response);
    }

    /**
     * 首页
     */
    public void requestHomes(long requestIndex) {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestHomesDada(requestIndex), new NetUtil.CacheNetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type,
                                        boolean outOfDate) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {

            }

            @Override
            public void onCacheResponse(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 首页 - 侧边栏
     */
    public void requestHomesLeftSidebar() {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestHomeLeftSidebar(), new NetUtil.CacheNetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type,
                                        boolean outOfDate) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
            }

            @Override
            public void onCacheResponse(NetParams netParams, JsonData data) {

            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 首页 - 侧边栏 - 雷达图
     */
    public void requestRadar() {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestRadar(), new NetUtil.CacheNetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type,
                                        boolean outOfDate) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
            }

            @Override
            public void onCacheResponse(NetParams netParams, JsonData data) {

            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 首页-侧边栏-雷达图，点击标签跳转列表。
     */
    public void requestRadarList(int radarId, long last_time) {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestRadarList(radarId, last_time),
                new NetUtil.CacheNetDataCallBack() {
                    @Override
                    public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type,
                                                boolean outOfDate) {
                        onRequestCallBackListener.onResponse(netParams, data);
                    }

                    @Override
                    public void onRequestFinish(NetParams netParams, JsonData data) {
                    }

                    @Override
                    public void onCacheResponse(NetParams netParams, JsonData data) {

                    }

                    @Override
                    public void onRequestFail(NetParams netParams, FailData failData) {
                        onRequestCallBackListener.onResponseError(netParams, failData);
                        handleErrorMsg(failData);
                    }
                });
    }

    /**
     * 分类下文章列表
     */
    public void requestCategoriesArticles(int categorieId, long last_time) {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestCategoriesArticles(categorieId, last_time), new NetUtil.CacheNetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type,
                                        boolean outOfDate) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {

            }

            @Override
            public void onCacheResponse(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponseCache(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 标签下文章列表
     */
    public void requestTagsArticles(int tagId, long last_time) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestTagsArticles(tagId, last_time), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 文章详情
     */
    public void requestArticleDetail(int artileId) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestArticleDetail(artileId), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 文章详情，与detail，这个是一些相关信息，比如作者等。
     */
    public void requestArticleInfo(int artileId) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestArticleInfo(artileId), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 问卷列表
     */
    public void requestRequestQuestionnaireLists(long paperId) {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestQuestionnaireLists(paperId), new NetUtil.CacheNetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type,
                                        boolean outOfDate) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
            }

            @Override
            public void onCacheResponse(NetParams netParams, JsonData data) {

            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 问卷详情
     */
    public void requestQuestionnaireDetail(int paperId) {
        NetUtil.getInstance(mContext).doGetWithCache(new NetConfigs.RequestQuestionnaireDetail(paperId), new NetUtil.CacheNetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data, CacheAbleRequest.ResultType type, boolean outOfDate) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
            }

            @Override
            public void onCacheResponse(NetParams netParams, JsonData data) {

            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 问卷详情
     */
    public void requestUserQuestionDetail(int paperId) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestUserQuestionDetail(paperId), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }


    /**
     * Mob详情
     */
    public void requestMobDetail(int mobId) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestMobDetail(mobId), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * Mob详情
     */
    public void requestMobOptions(int mobId, long lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestMobOptions(mobId, lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 问卷评论
     */
    public void requestQuestionnaireComments(int paperId, long lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestQuestionnaireComments(paperId, lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 文章评论
     */
    public void requestArticleComments(int articleId, long lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestArticleComments(articleId, lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 用户设置
     */
    public void requestUserSettings() {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestUserSettings(), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 我赞过的
     */
    public void requestMyPraises(int lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestMyPraises(lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 我的评论（GET）
     */
    public void requestMyComments(int lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestMyComments(lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 评论过我的（GET）
     */
    public void requestCommentOnMy(int lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestCommentOnMy(lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 用户中心（GET）
     */
    public void requestUserCenter() {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestUserCenter(), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 搜索（GET）
     */
    public void requestSearch(String search, int last_time) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestSearch(search, last_time), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 赞过我的（GET）
     */
    public void requestPraisesOnMy(int lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestPraisesOnMy(lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 我的生活研究所（GET）
     */
    public void requestMyLifeInstitute(int lastTime) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestMyLifeInstitute(lastTime), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }
    ////////////////////////////////////////////////////POST////////////////////////////////////////////////////////////

    /**
     * 发表评论（POST）
     */
    public void requestSendComment(String commentType, String content, int typeId, int commentId) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestSendComment(commentType, content, typeId, commentId), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 赞（POST）
     */
    public void requestLikeIt(String praise_type, int typeId, int genre) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestLikeIt(praise_type, typeId, genre), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 登入（POST）
     */
    public void requestSignin(String email, String password) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestSignin(email, password), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                if (failData.getErrorType() == FailData.ERROR_DATA_FORMAT)
                {
                    ToastUtil.showToast(mContext, "用户名或密码错误");
                }
                else
                {
                    handleErrorMsg(failData);
                }
            }
        });
    }

    /**
     * 社交登陆于绑定（POST）
     */
    public void requestSocialAction(String uid, String token, String username, String face, int socialType) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestSocialAction(uid, token, username, face, socialType), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 用户注册 第一步验证（POST）
     */
    public void requestRegisterFirstStep(String email, String password) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestRegisterFirstStep(email, password),
                new NetDataCallBack() {
                    @Override
                    public void onRequestFinish(NetParams netParams, JsonData data) {
                        onRequestCallBackListener.onResponse(netParams, data);
                    }

                    @Override
                    public void onRequestFail(NetParams netParams, FailData failData) {
                        onRequestCallBackListener.onResponseError(netParams, failData);
                        handleErrorMsg(failData);
                    }
                });
    }

    /**
     * 用户注册（POST）
     */
    public void requestRegister(String email, String password, String description, String username, File face) {
        NetUtil.getInstance(mContext).doUploadFile(new NetConfigs.RequestRegister(email, password, description, username, face), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 找回密码（POST）
     */
    public void requestfindPassword(String email) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestfindPassword(email), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * Mob上传选项（POST）
     */
    public void requestUploadMob(int paper_id, String title, File image) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestUploadMob(paper_id, title, image), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 用户反馈（POST）
     */
    public void requestFeedbacks(String feedbackTitle, String feedbackContent) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestFeedbacks(feedbackTitle, feedbackContent), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }


    /**
     * 解除绑定（POST）
     */
    public void requestUnBinding(int social) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestUnBinding(social), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 修改个人信息（POST）
     */
    public void requestUpdatePersonalInformation(File face, String userName, String description, String email) {
        NetUtil.getInstance(mContext).doUploadFile(new NetConfigs.RequestUpdatePersonalInformation(face, userName, description, email), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * Mob问卷点赞（POST）
     */
    public void requestMobLiked(int optionId, int genre) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestMobLiked(optionId, genre), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 普通问卷提交选项（POST）
     */
    public void requestSubmitOptions(int paper_id, String options) {
        NetUtil.getInstance(mContext).doPost(new NetConfigs.RequestSubmitOptions(paper_id, options), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * 我的收藏（POST）
     */
    public void requestMyFavorite(long last_time) {
        NetUtil.getInstance(mContext).doGet(new NetConfigs.RequestMyFavorite(last_time), new NetDataCallBack() {
            @Override
            public void onRequestFinish(NetParams netParams, JsonData data) {
                onRequestCallBackListener.onResponse(netParams, data);
            }

            @Override
            public void onRequestFail(NetParams netParams, FailData failData) {
                onRequestCallBackListener.onResponseError(netParams, failData);
                handleErrorMsg(failData);
            }
        });
    }

    /**
     * ****************************PUT**********************************
     */

    /**
     * 修改密码
     *
     * @param urlString
     * @param cookie
     * @param params
     * @param handler
     */
    public void requestChangePwd(String urlString, String cookie, String params, Handler handler) {
        QDUtil.requestHttp(urlString, cookie, "PUT", params, handler);
    }

    /**
     * ***************DELETE**********************************
     */

    /**
     * 用户退出（delete）
     */
    public void requestSingOut(String urlString, String cookie, String params, Handler handler) {
        QDUtil.requestHttp(urlString, cookie, "DELETE", params, handler);
    }

    private void handleErrorMsg(FailData failData) {
        String errString = "未知错误";
        if (failData.getErrorType() == FailData.ERROR_UNKNOWN) {
            errString = "未知错误";
        } else if (failData.getErrorType() == FailData.ERROR_INPUT) {
            errString = "无效的参数请求";
        } else if (failData.getErrorType() == FailData.ERROR_NETWORK) {
            errString = "网络异常,请稍后再试";
        } else if (failData.getErrorType() == FailData.ERROR_DATA_FORMAT) {
            errString = "数据解析失败";
        }
        QLog.d("handleErrorMsg", null != failData.getRawData() ? failData.getRawData().toString() : "");
        ToastUtil.showToast(mContext, errString);
    }
}
